import { createRouter, createWebHashHistory } from 'vue-router'
// import HomeView from '../views/HomeView.vue'
import CountyChronicle from '../views/CountyChronicle/index.vue'



const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'index',
      redirect: '/county'
      // component: HomeView
    },
    {
      path: '/county',
      name: 'county',
      component: CountyChronicle, //县志
    },
    {
      path: '/township',
      name: 'TownshipChronicle',
      component: () => import('../views/TownshipChronicle/index.vue'), //乡镇志
    },
    {
      path: '/village',
      name: 'village',
      component: () => import('../views/VillageChronicle/index.vue'), //村志
    },
    {
      path: '/text_books',
      name: 'village',
      component: () => import('../views/TextBooks/index.vue'), //村志电子书
    }
  ],
  // 添加滚动行为配置
  scrollBehavior(to, from, savedPosition) {
    // 如果有保存的位置（浏览器前进/后退），则使用保存的位置
    if (savedPosition) {
      return savedPosition
    }
    // 否则滚动到顶部
    return { top: 0 }
  }
})

export default router
